home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.lib;
- import sub_arctic.lib.sub_arctic_error;
-
- /**
- * This is a small interactor subclass that just adds part_a and part_b
- * functionality to base_interactor. It implements part_a and
- * part_b as simple integer attributes (i.e., not tied to anything else)
- * and is useful either as a base class for something that needs parts,
- * or as a intermediary to pass on a value or compute an additional quantity.
- * The source of this class is also a good guide to how to add part_a or part_b
- * functionality to an existing class.
- *
- * @author Scott Hudson
- */
- public class interactor_with_parts extends base_interactor {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate which values (coordinates/sizes) of this object are
- * intrinsically constrained by the internals of the object. In this
- * case we need to remove PART_A and PART_B from the set reported by our
- * superclass.
- *
- * @return int the set of parts intrinsically constrained.
- */
- public int intrinsic_constraints()
- {
- return super.intrinsic_constraints() & ~(PART_A|PART_B);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Storage for part_a value */
- protected int _part_a = 0;
-
- /** Storage for part_b value */
- protected int _part_b = 0;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the value of part_a after evaluating any attached constraints.
- * @return int the up-to-date value of part_a.
- */
- public int part_a()
- {
- /* evaluate and return the value */
- eval_part_a();
- return _part_a;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set part_a value directly bypassing the constraint system.
- * @param int v new value for part_a.
- */
- protected void set_raw_part_a(int v)
- {
- /* don't do anything unless this is a change */
- if (v != _part_a)
- {
- /* change the value and damage our image */
- _part_a = v;
- damage_self();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set part_a of object.
- * @param int v new value for part_a
- */
- public void set_part_a(int v)
- {
- /* if this has a constraint throw an exception */
- if ((active_constraints() & PART_A) != 0)
- throw new sub_arctic_error(
- "Attempt to assign value to constrained part_a");
-
- /* don't do anything unless this is a change */
- if (v != _part_a)
- {
- set_raw_part_a(v);
- mark_part_a_ood();
- }
- }
-
- //had:
- //* @exception cannot_assign if part_a is controlled by a constraint.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the value of part_b after evaluating any attached constraints.
- * @return int the up-to-date value of part_b.
- */
- public int part_b()
- {
- /* evaluate and return the value */
- eval_part_b();
- return _part_b;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set part_b value directly bypassing the constraint system.
- * @param int v the new value for part_b.
- */
- protected void set_raw_part_b(int v)
- {
- /* don't do anything unless this is a change */
- if (v != _part_b)
- {
- /* change the value and damage our image */
- _part_b = v;
- damage_self();
- }
- }
-
- //had:
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set part_b of object.
- * @param int v new value for part_b.
- */
- public void set_part_b(int v)
- {
- /* if this has a constraint throw an exception */
- if ((active_constraints() & PART_B) != 0)
- throw new sub_arctic_error(
- "Attempt to assign value to constrained part_b");
-
- /* don't do anything unless this is a change */
- if (v != _part_b)
- {
- set_raw_part_b(v);
- mark_part_b_ood();
- }
- }
-
- //had:
- //* @exception cannot_assign if part is controlled by a constraint.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Full constructor.
- * @param int x_v the initial x position of the interactor.
- * @param int y_v the initial y position of the interactor.
- * @param int w_v the initial width of the interactor.
- * @param int h_v the initial height of the interactor.
- */
- public interactor_with_parts(int x_v, int y_v, int w_v, int h_v)
- {
- super(x_v, y_v, w_v, h_v);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor that assumes a (temporary) default size
- * @param int x_v the initial x position of the interactor.
- * @param int y_v the initial y position of the interactor.
- */
- public interactor_with_parts(int x_v, int y_v)
- {
- super(x_v, y_v);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor that assumes a position of 0,0, and a (temporary) default
- * size.
- */
- public interactor_with_parts()
- {
- super();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-